import http from '../http.js'

const MODULE_PREFIX = '/i'

/**
 * 获取地理坐标信息列表
 * @param {Object} params 查询参数
 * @param {number} params.page 当前页码
 * @param {number} params.size 每页显示条数
 * @returns {Promise}
 */
export function listLocation(params = {}) {
  const { page = 1, size = 20, keyword } = params
  return http.get(MODULE_PREFIX + '/admin/location/list', {
    params: {
      page,
      size,
      keyword
    }
  })
}

export function saveLocation(data) {
  return http.post(MODULE_PREFIX + '/admin/location/save', data)
}

export function deleteLocation(ids) {
  return http.delete(MODULE_PREFIX + '/admin/location/delete', { data: ids })
}

export async function getAllLocations() {
  return request({
    url: '/admin/location/list',
    method: 'get',
    params: {
      page: 1,
      size: 1000 // 获取足够大的数据量确保拿到全部
    }
  })
}
